package com.project.service.impl;

import com.project.bean.StudentBean;
import com.project.mapper.IStudentMapper;
import com.project.service.IStudentService;
import org.apache.ibatis.session.SqlSession;

/***
 * 学生业务层实现类
 */
public class StudentServiceImpl extends BaseService implements IStudentService {
    @Override
    public void add(StudentBean studentBean) {
        //得到SqlSession
        SqlSession sqlSession = this.getSession();
        //得到IEmployeeMapper实现类对象
        IStudentMapper mapper =   sqlSession.getMapper(IStudentMapper.class);
        mapper.add(studentBean);
        //提交事务
        sqlSession.commit();
        //关闭sqlSession
        sqlSession.close();
    }

    @Override
    public void del(int id) {
         SqlSession session = this.getSession();
        IStudentMapper mapper =   session.getMapper(IStudentMapper.class);
        mapper.del(id);
        session.commit();
        session.close();
    }

    @Override
    public void update(int id, String newPhone) {
       SqlSession session = this.getSession();
       IStudentMapper mapper =   session.getMapper(IStudentMapper.class);
       mapper.update(id,newPhone);
       session.commit();
       session.close();
    }
}
